package com.jzr.board.db1.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jzr.board.db1.dto.VitalSignDto;
import com.jzr.board.db1.mapper.MyPatientMapper;
import com.jzr.board.db1.mapper.TVitalSignMapper;
import com.jzr.board.db1.model.TPatient;
import com.jzr.board.db1.model.TVitalSign;
import com.jzr.board.db1.service.TVitalSignService;
import com.jzr.board.db1.vo.PatientBaseVo;
import com.jzr.common.date.DateUtil;
import com.jzr.common.util.U;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TVitalSignServiceImpl extends ServiceImpl<TVitalSignMapper,TVitalSign> implements TVitalSignService {
    @Autowired
    MyPatientMapper patientMapper;

    @Override
    public List<TVitalSign> getVitalSignList(VitalSignDto record) {
        if(U.isBlank(record.getPatientCureNo())){
            return null;
        }
        QueryWrapper<TVitalSign> qw = new QueryWrapper<>();
        if(U.isNotBlank(record.getPatientCode())){
            qw.eq(TVitalSign.PatientCode_,record.getPatientCode());
        }
        qw.eq(TVitalSign.PatientCureNo_,record.getPatientCureNo());

        if(U.isNotBlank(record.getOpDateFrom())) {
            qw.ge(TVitalSign.OpDate_,record.getOpDateFrom());
        }

        if(U.isNotBlank(record.getOpDateTo())) {
            record.setOpDateTo(DateUtil.addDays(record.getOpDateTo(),1));
            qw.lt(TVitalSign.OpDate_,record.getOpDateTo());
        }

        return baseMapper.selectList(qw);
    }

    @Override
    public List<PatientBaseVo> getPatentList(TPatient record) {
        return patientMapper.getPatentBaseList(record);
    }

}
